﻿@using WineStore.Extends;
@using PagedList.Mvc;
@using PagedList;
@model PagedList.IPagedList<WineStore.Models.Order>
@{
    ViewBag.Title = "ShowOrderByStatus";
    Layout = "~/Views/Shared/AdminLayout.cshtml";
}
@section Styles
{
    <!--Sử dụng cho autocomplete-->
    <link href="../../Content/themes/base/jquery.ui.all.css" rel="stylesheet" type="text/css" />
    <!--Sử dụng cho paging-->
    <link href="../../Content/PagedList.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        td {
            text-align: center;
            vertical-align: middle;
        }

        input, textarea, select {
            padding: 5px;
            border: 1px solid #ccc;
            border-radius: 3px;
            width: 200px;
            color: #333;
            box-shadow: rgba(0,0,0,0.1)0px 0px 8px;
            -moz-box-shadow: rgba(0,0,0,0.1)0px 0px 8px;
            -webkit-box-shadow: rgba(0,0,0,0.1)0px 0px 8px;
        }

        textarea {
            width: 400px;
            height: 100px;
            max-width: 400px;
            line-height: 18px;
            border-radius: 3px;
        }


            input:hover, textarea:hover, select:hover, input:focus, textarea:focus, select:focus {
                border-color: 10px solid #C9C9C9;
                box-shadow: rgba(0,0,0,0.2)0px 0px 8px;
                -moz-box-shadow: rgba(0,0,0,0.2)0px 0px 8px;
                -webkit-box-shadow: rgba(0,0,0,0.2)0px 0px 8px;
                border-radius: 3px;
            }

        input .submit {
            height: 38px;
            background-color: #474E69;
            color: #FFF;
            border-radius: 3px;
            -moz-border-radius: 3px;
            -webkit-border-radius: 3px;
        }

        #menu_status {
            position: relative;
            left: 570px;
            top: -38px;
        }

            #menu_status ul {
                margin: 0px;
                padding: 0px;
                list-style-type: none;
            }

            #menu_status li {
                float: left;
                margin-right: 0.5em;
            }

            #menu_status a {
                display: block;
                width: 8em;
                color: white;
                background-color: #0074B3;
                text-decoration: none;
                text-align: center;
            }
    </style>
}
@section Scripts
{
    <!--Sử dụng cho autocomplete-->
    <script src="../../Scripts/jquery-ui-1.8.11.min.js" type="text/javascript"></script>
    <!--Sử dụng cho autocomplete-->
    <script type="text/javascript" language="javascript">
        $(document).ready(function () {
            $('*[data-autocomplete-url]')
        .each(function () {
            $(this).autocomplete({
                source: $(this).data("autocomplete-url")
            });
        });
        });
    </script>
    <!--Sử dụng cho row hover-->
    <script type="text/javascript">
        $(document).ready(function () {
            $("tr").not(':first').hover(function () {
                $(this).css("background", "#F0FFFF");
            }, function () {
                $(this).css("background", "");
            });
        });
    </script>
}
<!-- Table (TABLE) -->
@if (Session["Admin"] != null)
{
    <h3 class="tit">Management Order
    </h3>
    using (Html.BeginForm())
    {
    <p>
        Customer Name:@Html.TextBox("SearchString", ViewBag.CurrentFilter as string, new { data_autocomplete_url = Url.Action("Autocomplete") })
        <input type="submit" value="Search" style="width: 70px; cursor: pointer; z-index: 0;" />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Show Orders By Status:
    </p>
        
    <div id="menu_status">
        <ul>
            <li>@Html.ActionLink("Pending", "ShowOrderByStatus", new { status = 1 })</li>
            <li>@Html.ActionLink("Active", "ShowOrderByStatus", new { status = 2 })</li>
            <li>@Html.ActionLink("Finish", "ShowOrderByStatus", new { status = 3 })</li>
        </ul>
    </div>
    <table border="1" style="width: 100%;">
        <tr>
            <th>Customer Name
            </th>
            <th>FullName (Shipping)
            </th>
            <th>Address (Shipping)
            </th>
            <th>Phone (Shipping)
            </th>
            <th>Email (Shipping)
            </th>
            <th>Total Price
            </th>
            <th>Order Date
            </th>
            <th>Status
            </th>
            <th>Event
            </th>
        </tr>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Html.DisplayFor(order => item.Customer.FullName)
                </td>
                <td>
                    @Html.DisplayFor(order => item.FullName)
                </td>
                <td>
                    @Html.DisplayFor(order => item.Address)
                </td>
                <td>
                    @Html.DisplayFor(order => item.Phone)
                </td>
                <td>
                    @Html.DisplayFor(order => item.Email)
                </td>
                <td>
                    @Html.DisplayFor(order => item.Total)
                </td>
                <td>
                    @Html.DisplayFor(order => item.OrderDate)
                </td>
                <td>@ViewBag.StatusDes&nbsp;
                    @{if (@ViewBag.Status == 1)
                      {
                        @Html.ActionLink("Active", "ChangeStatus", new { id = item.OrderId, status = ViewBag.Status,currentFilter = ViewBag.CurrentFilter })
                      }
                      else if (@ViewBag.Status == 2)
                      {
                        @Html.ActionLink("Finish", "ChangeStatus", new { id = item.OrderId, status = ViewBag.Status,currentFilter = ViewBag.CurrentFilter })
                      }
                    }
                </td>
                <td>
                    @Html.ActionLink("Detail", "ShowOrderDetail", "OrderDetail", new { orderId = item.OrderId }, null)&nbsp;
                    @Html.ActionLink("Cancel", "DeleteOrder", new { id = item.OrderId })
                </td>
            </tr>
        }
    </table>
    <!--Paging-->
    @Html.PagedListPager(Model, page => Url.Action("ShowOrderByStatus", new { status = ViewBag.Status, page = page, currentFilter = ViewBag.CurrentFilter }), (PagedListRenderOptions)ViewBag.Pro)
    }
}
else
{
    Response.Redirect("~/Admin/LogOn/");
}